from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# Open Chrome browser and navigate to the website
driver = webdriver.Chrome()
driver.get("https://the-internet.herokuapp.com/dynamic_content")

# Verify that the page displays three images
images = driver.find_elements(By.CSS_SELECTOR, "div#content > div.row > div > img")
if len(images) == 3:
    print("网页上有三张图片")

# Click the "click here" button to change the images
shuffle_link = driver.find_element(By.LINK_TEXT, "click here")
shuffle_link.click()

# Wait for the new images to load and verify that there are still three images displayed
new_images = WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "div#content > div.row > div > img")))
if len(new_images) == 3:
    print("新图片有三张")


# Close the browser
driver.quit()
